<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Symbol创建对象属性</title>
  </head>

  <body>

  </body>
  <script>
    /* 
    Symbol创建对象添加方法up,down
     */
    // 第一种方式：
    let game = {
      up: "英雄联盟",
      down: "穿越火线"
    }
    //1.先声明一个对象
    let methods = {
      up: Symbol(),
      down: Symbol()
    }
    //2.向对象里扩展方法
    game[methods.up] = function () {
      console.log("我可以玩盖伦");
    }
    game[methods.down] = function () {
      console.log("我玩得很菜");
    }
    console.log(game);

    // 第二种方式：向对象里添加一个独一无二的属性
    let anotherGame = {
      name: "狼人杀",
      [Symbol("say")]: function () {
        console.log("我是个狼人");
      },
      [Symbol("play")]: function () {
        console.log("我是个平民");
      }
    }
    console.log(anotherGame);
  </script>

</html>